<template>
	<view style="width: 100%;height: 100%;" class="indexglobal">
		<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar
					title="首页" @clickLeft="back" title-align="left" />
		<!-- <view class="searchshangjia">

<uni-search-bar @confirm="" @input="" />
</view> -->
<uni-search-bar @confirm="" @input="" />
		<swiper circular autoplay :interval="3000" :duration="500" indicator-dots style="height: 350rpx;"
			indicator-color="rgba(255, 255, 255, 0.6)" indicator-active-color="#3CB371">
			<swiper-item v-for="item in banners" :key="item.id">
				<image :src="item.img" alt="" style="width: 100%;height:350rpx;" />
			</swiper-item>
		</swiper>

		<view class="title">
			热门商家
		</view>
		<view class="businesslist" v-for="item in businesslist" @click="todetail(item.id)">
			<view class="logoimage">
				<image :src="item.avatar" mode=""></image>
			</view>
			<view class="businfo" >
				 <view style="font-size: 36rpx; font-weight: bold;">{{item.name}}</view>
				
				      <view style="display: flex;  color: #666; ">
				        <view style="flex: 1;">
				          <text style="color: #ff9800; font-weight: bold;">4.5分</text>
				          <text style="margin-left: 10rpx;">已售30</text>
				        </view>
				        <view style="flex: 1; text-align: right;">30分钟内送达</text>
				        </view>
				      </view>
				      
				      <view style="color: #ff9800;">免配送费</view>
				      
				      <view style="background-color: #ffd281; color: brown; border-radius: 4rpx; width: fit-content;
				        padding: 0 8rpx;">{{ item.info || '商家介绍' }}</view>

			</view>
		

		</view>

	</view>
</template>

<script>
	import $H from '../../utils/request.js';
	export default {
		data() {
			return {
				banners: [],
				businesslist:[]
			}
		},
		mounted() {
			this.getbanner()
						this.getbusiness()
		},
		methods: {
			todetail(id){
				uni.navigateTo({
					url:"/pages/bus_detail/bus_detail?id="+id
				})
			},
			getbusiness(){
		$H.get("Business/all",{},{token:true}).then(res => {
				console.log(res);
				this.businesslist = res.list
			})
				
			},
			getbanner() {
				$H.post("Banner/getall").then(res => {
					console.log(res);
					this.banners = res
				})
			}
		}
	}
</script>

<style>
	.indexglobal {
		background: #e5e5e5;
	}
	.businfo{
		width: calc(100% - 88px);
	}
	.logoimage{
		width: 90px;
		height: 90px;
		margin-right: 10px;
	}
		.logoimage image{
			width: 100%;
			height: 100%;
		}

	.businesslist {
		width: 100%;
		height: auto;
		padding: 10px;
		box-sizing: border-box;
		background: #fff;
		display: flex;
		align-items: center;
	}

	.searchshangjia {
		width: 100%;
		height: 36px;
		line-height: 36px;
	}

	.searchshangjia input {
		width: 100%;
		height: 100%;
	}

	.searchshangjia input::placeholder {
		width: 100%;
		margin: 0 auto;
		text-align: center;
	}

	.title {
		width: 100%;
		height: auto;
		padding: 10px;
		box-sizing: border-box;
		color: rgb(242, 41, 66);
		font-size: 17px;
		font-weight: bold;
		background: #fff;
		margin: 10px 0px;
	}
</style>
